package homeWork.five.demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2022-12-11
 * Time: 18:47
 */

import java.util.Scanner;
import java.util.Vector;

/**
 *  编写一个Java应用程序，要求使用Vector向量保存用户输入的若干个字符串
 *  并显示出来:同时在所有字符串的中间位置插入“NICE”，再次显示所有字符串。
 */
public class TestDemo {
    public static void main(String[] args) {
        Vector<String> vector = new Vector<>();
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入字符串~~~");
        //假定输入5个字符串
        int n= 5;
        for(int i =0;i<n;++i){
            String str = scanner.next();
            vector.addElement(str);
        }
        //future beautiful unbelievable synchronized volatile
        vector.insertElementAt("NICE",n/2);
        System.out.println(vector);
    }

}
